package com.acc.service;

import java.util.List;

import com.acc.dao.HelloDAO;
import com.acc.entity.User;
/**
 * 
 * @author 杨天然
 *
 */
public class HelloService {
	private HelloDAO hellodao = new HelloDAO();

	/**
	 * 
	 * @param pageNum:页数
	 * @param pageSize:页码
	 * @return:分页查询的数据
	 */
	public List<User> getPage(int pageNum, int pageSize) {

		String sql = "select * from (select employee.*, rownum num from employee where"
				+ " rownum <=? ) t where t.num >= ?";

		List<User> list = hellodao.getUsers(sql, pageNum * pageSize, (pageNum-1) * pageSize);

		return list;
	}

	/*
	 * 取得所有用户信息
	 */
	public List<User> getUser() {
		// TODO Auto-generated method stub
		String sql = "select * from ti_user";
		List<User> list = hellodao.getUsers(sql);
		return list;
	}

	/*
	 * 增加用户信息
	 */
	public User getOne(String name, String password) {
		// TODO Auto-generated method stub
		String sql = "select * from ti_user where user_name=? and password=?";
		User user = hellodao.getOne(sql, name, password);
		return user;
	}

	public void add(User user) {
		// TODO Auto-generated method stub
		HelloDAO helloDao=new HelloDAO();
		helloDao.addUser(user.getUserName(), user.getPassword(), user.getGender(), user.getIdcard(), user.getType());
	}

	public List<String> getAllProvince() {
		// TODO Auto-generated method stub
		List<String> provinces = hellodao.getAllProvince();
		return provinces;
	}

	public List<String> getAllCityByProvince(String province) {
		List<String> cities = hellodao.getAllCitiesByProvince(province);
		// TODO Auto-generated method stub
		return cities;
	}



}
